using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;
using System.Xml.Serialization;

using Business = Microsoft.ConnectionEngine.Administration.Core.ServiceProvider.Business;
using Common = Microsoft.ConnectionEngine.Registers.Core.ServiceProvider.Common;
using Security = Microsoft.ConnectionEngine.Common.Security;
using System.Security.Principal;


/// <summary>
/// Provides a facade layer to the business layer. 
/// </summary>
[WebService(Namespace = "http://Microsoft.ConnectionEngine.Administration.Services")]
public class AdminServices : System.Web.Services.WebService
{

    public AdminServices()
    {
        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    #region ReferenceData
    [WebMethod]
    public Common.ReferenceData GetReferenceData()
    {
        return Business.RefDataManager.GetRefData();
    }
    #endregion

    # region Security
    [WebMethod]    
    public Security.HSDPrincipal ValidateUser(string username, string password)
    {
        return Business.SecurityManager.ValidateUser(username, password);        
        
    }
    #endregion

    #region MessageType
    [WebMethod]
    public Common.MessageTypesList MessageTypeSearch(
        Security.HSDPrincipal principal, Common.MessageTypeSearchRequest messageTypeSearchRequest)
    {
        return Business.MessageTypeManager.Search(principal, messageTypeSearchRequest);
    }

    [WebMethod]
    public Common.MessageType MessageTypeSelectItem(Security.HSDPrincipal principal, int messageTypeID)
    {
        return Business.MessageTypeManager.SelectItem(principal, messageTypeID);
    }

    [WebMethod]
    public Common.MessageType MessageTypeLock(Security.HSDPrincipal principal, int messageTypeID)
    {
        return Business.MessageTypeManager.Lock(principal, messageTypeID);
    }

    [WebMethod]
    public bool MessageTypeUnlock(Security.HSDPrincipal principal, int messageTypeID)
    {
        return Business.MessageTypeManager.Unlock(principal, messageTypeID);
    }

    [WebMethod]
    public bool MessageTypeUnlockAll(Security.HSDPrincipal principal)
    {
        return Business.MessageTypeManager.UnlockAll(principal);
    }

    [WebMethod]
    public int MessageTypeInsert(Security.HSDPrincipal principal, Common.MessageType messageType)
    {
        return Business.MessageTypeManager.Insert(principal, messageType);
    }

    [WebMethod]
    public bool MessageTypeUpdate(Security.HSDPrincipal principal, Common.MessageType messageType)
    {
        return Business.MessageTypeManager.Update(principal, messageType);
    }

    [WebMethod]
    public bool MessageTypeDelete(Security.HSDPrincipal principal, int messageTypeID)
    {
        return Business.MessageTypeManager.Delete(principal, messageTypeID);
    }
    #endregion

    #region Pool

    [WebMethod]
    public Common.Pools PoolSearch(Security.HSDPrincipal principal, Common.PoolSearchRequest poolSearchRequest)
    {
        return Business.PoolManager.Search(principal, poolSearchRequest);
    }

    [WebMethod]
    public Common.Pool PoolSelectItem(Security.HSDPrincipal principal, int poolID)
    {
        return Business.PoolManager.SelectItem(principal, poolID);
    }

    [WebMethod]    
    public Common.Pool PoolLock(Security.HSDPrincipal principal, int PoolID)
    {
        return Business.PoolManager.Lock(principal, PoolID);
    }

    [WebMethod]
    public bool PoolUnlock(Security.HSDPrincipal principal, int PoolID)
    {
        return Business.PoolManager.Unlock(principal, PoolID);
    }

    [WebMethod]
    public bool PoolUnlockAll(Security.HSDPrincipal principal)
    {
        return Business.PoolManager.UnlockAll(principal);
    }

    [WebMethod]
    public int PoolInsert(Security.HSDPrincipal principal, Common.Pool pool)
    {
        return Business.PoolManager.Insert(principal, pool);
    }

    [WebMethod]
    public bool PoolUpdate(Security.HSDPrincipal principal, Common.Pool pool)
    {
        return Business.PoolManager.Update(principal, pool);
    }

    [WebMethod]
    public bool PoolDelete(Security.HSDPrincipal principal, int PoolID)
    {
        return Business.PoolManager.Delete(principal, PoolID);
    }

    #endregion

    #region Service Provider
    [WebMethod]
    public Common.ServiceProviders ServiceProviderSearch(Security.HSDPrincipal principal, Common.ServiceProviderSearchRequest serviceProviderSearchRequest)
    {
        return Business.ServiceProviderManager.Search(principal, serviceProviderSearchRequest);        
    }

    [WebMethod]
    public Common.ServiceProvider ServiceProviderSelectItem(Security.HSDPrincipal principal, int serviceProviderID)
    {
        return Business.ServiceProviderManager.SelectItem(principal, serviceProviderID);
    }

    [WebMethod]
    public Common.ServiceProvider ServiceProviderLock(Security.HSDPrincipal principal, string serviceProviderID)
    {
        return Business.ServiceProviderManager.Lock(principal, serviceProviderID);
    }

    [WebMethod]
    public bool ServiceProviderUnlock(Security.HSDPrincipal principal, string serviceProviderID)
    {
        return Business.ServiceProviderManager.Unlock(principal, serviceProviderID);
    }
    [WebMethod]
    public bool ServiceProviderUnlockAll(Security.HSDPrincipal principal)
    {
        return Business.ServiceProviderManager.UnlockAll(principal);
    }

    [WebMethod]
    public string ServiceProviderInsert(Security.HSDPrincipal principal, Common.ServiceProvider serviceProvider)
    {
        return Business.ServiceProviderManager.Insert(principal, serviceProvider);
    }

    [WebMethod]
    public bool ServiceProviderUpdate(Security.HSDPrincipal principal, Common.ServiceProvider serviceProvider)
    {
        return Business.ServiceProviderManager.Update(principal, serviceProvider);
    }

    [WebMethod]
    public bool ServiceProviderDelete(Security.HSDPrincipal principal, string serviceProviderID)
    {
        return Business.ServiceProviderManager.Delete(principal, serviceProviderID);
    }
    #endregion

    #region ServiceProviderType
    [WebMethod]
    public Common.ServiceProviderTypes ServiceProviderTypeSearch(
        Security.HSDPrincipal principal, Common.ServiceProviderTypeSearchRequest providerTypeSearchRequest)
    {
        return Business.ServiceProviderTypeManager.Search(principal, providerTypeSearchRequest);
    }

    [WebMethod]
    public Common.ServiceProviderType ServiceProviderTypeSelectItem(Security.HSDPrincipal principal, int serviceProviderTypeID)
    {
        return Business.ServiceProviderTypeManager.SelectItem(principal, serviceProviderTypeID);
    }

    [WebMethod]
    public Common.ServiceProviderType ServiceProviderTypeLock(Security.HSDPrincipal principal, int ServiceProviderTypeID)
    {
        return Business.ServiceProviderTypeManager.Lock(principal, ServiceProviderTypeID);
    }

    [WebMethod]
    public bool ServiceProviderTypeUnlock(Security.HSDPrincipal principal, int ServiceProviderTypeID)
    {
        return Business.ServiceProviderTypeManager.Unlock(principal, ServiceProviderTypeID);
    }

    [WebMethod]
    public bool ServiceProviderTypeUnlockAll(Security.HSDPrincipal principal)
    {
        return Business.ServiceProviderTypeManager.UnlockAll(principal);
    }

    [WebMethod]
    public int ServiceProviderTypeInsert(Security.HSDPrincipal principal, Common.ServiceProviderType providerType)
    {
        return Business.ServiceProviderTypeManager.Insert(principal, providerType);
    }

    [WebMethod]
    public bool ServiceProviderTypeUpdate(Security.HSDPrincipal principal, Common.ServiceProviderType providerType)
    {
        return Business.ServiceProviderTypeManager.Update(principal, providerType);
    }

    [WebMethod]
    public bool ServiceProviderTypeDelete(Security.HSDPrincipal principal, int ServiceProviderTypeID)
    {
        return Business.ServiceProviderTypeManager.Delete(principal, ServiceProviderTypeID);
    }
    #endregion
    
    #region Pool - ServiceProviderType
    [WebMethod]
    public Common.PoolServiceProviderTypes PoolServiceProviderTypeLinkSearch(Security.HSDPrincipal principal, string PoolID, string serviceProviderTypeID)
    {
        return Business.PoolServiceProviderTypeManager.PoolServiceProviderTypeLinkSearch(principal, PoolID, serviceProviderTypeID);
    }

    //[WebMethod]
    //public bool PoolServiceProviderTypeLinkInsert(Security.HSDPrincipal principal, int poolID, int serviceProviderTypeID)
    //{
    //    return Business.PoolServiceProviderTypeManager.PoolServiceProviderTypeLinkInsert(principal, poolID, serviceProviderTypeID);
    //}

    [WebMethod]
    public bool PoolServiceProviderTypeLinkInsert(Security.HSDPrincipal principal, Common.PoolServiceProviderTypeLink poolSptLink)
    {
        return Business.PoolServiceProviderTypeManager.PoolServiceProviderTypeLinkInsert(principal, poolSptLink);
    }

    [WebMethod]
    public bool PoolServiceProviderTypeLinksInsert(Security.HSDPrincipal principal, Common.PoolServiceProviderTypeLinks poolsptLinks)
    {
        return Business.PoolServiceProviderTypeManager.PoolServiceProviderTypeLinksInsert(principal, poolsptLinks);
    }

    [WebMethod]
    public bool PoolServiceProviderTypeLinksDelete(Security.HSDPrincipal principal, Common.PoolServiceProviderTypeLinks poolsptLinks)
    {
        return Business.PoolServiceProviderTypeManager.PoolServiceProviderTypeLinksDelete(principal, poolsptLinks);
    }

    //[WebMethod]
    //public bool PoolServiceProviderTypeLinkDelete(Security.HSDPrincipal principal, int poolID, int serviceProviderTypeID)
    //{
    //    return Business.PoolServiceProviderTypeManager.PoolServiceProviderTypeLinkDelete(principal, poolID, serviceProviderTypeID);
    //}

    [WebMethod]
    public bool PoolServiceProviderTypeLinkDelete(Security.HSDPrincipal principal, Common.PoolServiceProviderTypeLink poolSptLink)
    {
        return Business.PoolServiceProviderTypeManager.PoolServiceProviderTypeLinkDelete(principal, poolSptLink);
    }

#endregion

    #region ServiceProviderType - MessageType
    [WebMethod]
    public Common.ServiceProviderTypeMessageTypes ServiceProviderTypeMessageTypeLinkSearch(Security.HSDPrincipal principal, string messageTypeID,
        string serviceProviderTypeID)
    {
        return Business.ServiceProviderTypeMessageTypeManager.ServiceProviderTypeMessageTypeLinkSearch(principal, messageTypeID, serviceProviderTypeID);
    }

    [WebMethod]
    public bool ServiceProviderTypeMessageTypeLinkInsert(Security.HSDPrincipal principal, int messageTypeID,
        int sourceServiceProviderTypeID, int destinationServiceProviderTypeID)
    {
        return Business.ServiceProviderTypeMessageTypeManager.ServiceProviderTypeMessageTypeLinkInsert(principal, messageTypeID,
            sourceServiceProviderTypeID, destinationServiceProviderTypeID);
    }

    //[WebMethod]
    //public bool ServiceProviderTypeMessageTypeLinkInsert(Security.HSDPrincipal principal, Common.ServiceProviderTypeMessageTypeLink sptMessageTypeLink)
    //{
    //    return Business.ServiceProviderTypeMessageTypeManager.ServiceProviderTypeMessageTypeLinkInsert(principal, sptMessageTypeLink);
    //}

    [WebMethod]
    public bool ServiceProviderTypeMessageTypeLinksInsert(Security.HSDPrincipal principal, Common.ServiceProviderTypeMessageTypeLinks sptMessageTypeLinks)
    {
        return Business.ServiceProviderTypeMessageTypeManager.ServiceProviderTypeMessageTypeLinksInsert(principal, sptMessageTypeLinks);
    }
   
    [WebMethod]
    public bool ServiceProviderTypeMessageTypeLinkDelete(Security.HSDPrincipal principal, int serviceProviderTypeMessageTypeID)
    {
        return Business.ServiceProviderTypeMessageTypeManager.ServiceProviderTypeMessageTypeLinkDelete
            (principal, serviceProviderTypeMessageTypeID);
    }

    [WebMethod]
    public bool ServiceProviderTypeMessageTypeLinksDelete(Security.HSDPrincipal principal, Common.ServiceProviderTypeMessageTypeLinks sptMessageTypeLinks)
    {
        return Business.ServiceProviderTypeMessageTypeManager.ServiceProviderTypeMessageTypeLinksDelete(principal, sptMessageTypeLinks);
    }
    #endregion

    #region ServiceProvider - Pool

    //singular
    [WebMethod]
    public bool ServiceProviderPoolInsert(Security.HSDPrincipal principal, int poolID, string serviceProviderID)
    {
        return Business.ServiceProviderPoolManager.ServiceProviderPoolInsert(principal, serviceProviderID, poolID);
    }
    //singular
    [WebMethod]
    public bool ServiceProviderPoolDelete(Security.HSDPrincipal principal, int poolID, string serviceProviderID)
    {
        return Business.ServiceProviderPoolManager.ServiceProviderPoolDelete(principal, serviceProviderID, poolID);
    }
    //List
    [WebMethod]
    public bool ServiceProviderPoolLinksInsert(Security.HSDPrincipal principal, Common.ServiceProviderPoolLinks serviceProviderPoolLinks)
    {
        return Business.ServiceProviderPoolManager.ServiceProviderPoolsLinksInsert(principal, serviceProviderPoolLinks);
    }
    //List
    [WebMethod]
    public bool ServiceProviderPoolLinksDelete(Security.HSDPrincipal principal, Common.ServiceProviderPoolLinks serviceProviderPoolLinks)
    {
        return Business.ServiceProviderPoolManager.ServiceProviderPoolsLinksDelete(principal, serviceProviderPoolLinks);
    }
    #endregion
}

